<script setup>
import {useHomeStore} from "@/stores/home";
const useStore = useHomeStore();
</script>

<template>
  <template v-if="useStore.currentWallpaperObject">
    <video
        v-if="useStore.currentWallpaperObject.type === 'dynamic'"
        class="background transition"
        :class="{'zoom-in': useStore.isMask}"
        :src="useStore.currentWallpaperObject.main.url"
        autoplay="autoplay"
        muted="muted"
        loop="loop"
    ></video>
    <img
        v-else-if="useStore.currentWallpaperObject.type === 'custom'"
        class="background transition"
        :class="{'zoom-in': useStore.isMask}"
        :src="`https://pandax.online/uploads/wallpapers/original/${useStore.currentWallpaperObject.main.url}`"
        alt=""
    />
    <img
        v-else
        class="background transition"
        :class="{'zoom-in': useStore.isMask}"
        :src="`/images/background/${useStore.currentWallpaperObject.main.url}`"
        alt=""
    />
  </template>
</template>

<style lang="less" scoped>
.background {
  animation: start .35s 0s 1 cubic-bezier(.96, .64, .32, .1);
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;

  &.zoom-in {
    transform: translate(-50%, -50%) scale(1.1);
  }
}

@keyframes start {
  0% {opacity: 0}
  100% {opacity: 1}
}
</style>